#!/usr/bin/python

import time, sys
from math import pow as power

""" 
A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. 

For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. 

Numbers are always displayed without leading zeros.
"""

def ispalindrome(x):
    if x < 1:
        return False
    x = str(x)
    if x == x[::-1]:
        return True
    return False

def getinteger():
    return raw_input('What is the integer? ')
    
    
def main():
    start = time.time()
    
    tests = [(0, False), (9, True), (808, True), (2133, False), 
    (199, False), (1999, False), (319887788993, False), (333321, False), 
    (111, True), (1111, True), (999, True), (9999, True), (99999, True)]    
  
    for pair in tests:
        num, ans = pair
        if ispalindrome(num) == ans:
            print '{0} -> {1} OK'.format(num, ans)
        if ispalindrome(num) != ans:
            print '{0} -> {1} FAIL'.format(num, ans)
    
    K = None
    while not K:
        i = getinteger()
        if len(str(i)) < 1000000:
            K = i
        
    while True:
        
            
# solution 1: 

if __name__ == '__main__':
  main()
"""

"""